<template>
    <div class="box1">
        <div class="top">
            <p class="title">男女比例</p>
            <p class="bg"></p>
        </div>
        <div class="sex">
            <div class="man">
                <img src="../../images/man.png">
            </div>
            <div class="woman">
                <img src="../../images/woman.png">
            </div>
        </div>
        <div class="rate">
            <p>男士58%</p>
            <p>女士42%</p>
        </div>
        <div class="charts" ref="charts"></div>
    </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'

let charts = ref()

onMounted(() => {
    let myvharts = echarts.init(charts.value)
    myvharts.setOption({
        title: {
            text: '男女比例图',
            textStyle: {
                //主标题颜色
                color: 'skyblue',
            },
            left: '40%',
        },
        xAxis: {
            show: false,
            min: 0,
            max: 100
        },
        yAxis: {
            show: false,
            type: 'category'
        },
        series: [
            {
                type: 'bar',
                data: [58],
                barWidth: 20,
                z: 100,
                itemStyle: {
                    borderRadius: 20
                }
            },
            {
                type: 'bar',
                data: [100],
                barWidth: 20,
                barGap: '-100%',
                itemStyle: {
                    color: 'red',
                    borderRadius: 20
                }
            },
        ],
        //布局组件 
        grid: {
            top: 0,
            bottom: 0,
            right: 0,
            left: 0
        }
    })
})
</script>

<style scoped lang="scss">
.box1 {
    background: url(../../images/dataScreen-main-lb.png) no-repeat;
    background-size: 100% 100%;
    margin-top: 10px;

    .top {
        margin-left: 20px;

        .title {
            color: white;
            font-size: 20px;
        }

        .bg {
            width: 68px;
            height: 7px;
            background: url(../../images//dataScreen-title.png) no-repeat;
            background-size: 100% 100%;
            margin: 10px 0;
        }
    }

    .sex {
        display: flex;
        justify-content: center;

        .man {
            width: 111px;
            height: 115px;
            margin: 40px 30px;
            background: url(../../images/man-bg.png) no-repeat;
            background-size: 100% 100%;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .woman {
            width: 111px;
            height: 115px;
            margin: 40px 30px;
            background: url(../../images/woman-bg.png) no-repeat;
            background-size: 100% 100%;
            display: flex;
            justify-content: center;
            align-items: center;
        }
    }

    .rate {
        display: flex;
        justify-content: space-between;
        color: white;
        padding: 0 10px;
    }

    .charts {
        height: 80px;
    }
}
</style>